package com.olddriver.crm.service.impl;

import com.olddriver.crm.domain.Systemlog;
import com.olddriver.crm.mapper.SystemlogMapper;
import com.olddriver.crm.page.PageResult;
import com.olddriver.crm.query.QueryObject;
import com.olddriver.crm.service.ISystemlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class SystemlogServiceImpl implements ISystemlogService{

    @Autowired
    private SystemlogMapper systemlogMapper;

    @Override
    public int insert(Systemlog systemlog){
        return systemlogMapper.insert(systemlog);
    }

    @Override
    public void deleteAll(QueryObject qo) {
        systemlogMapper.deleteAll(qo);
    }

    @Override
    public List<Systemlog> listAll() {
        return systemlogMapper.listAll();
    }

    @Override
    public PageResult query(QueryObject qo) {
        int total = systemlogMapper.getTotal(qo);
        if (total == 0) {
            return new PageResult(total, Collections.emptyList());
        }else {
            return new PageResult(total,systemlogMapper.getLogs(qo));
        }
    }
}
